/* 
 *   Date       Developer   Description
 *   
 *
 *   Classname:  zzz.utils.CamelUtils
 * 
 *   Date:   2014-3-7
 * 
 *   The source code contained in this listing is proprietary to
 *   HLJ POST YITONG INFO-NET CO.,LTD.
 * 
 *   Unauthorized copying, adaptation, distribution, use, or display
 *   is strictly prohibited.
 *   This software is Copyright 2014 HLJ POST YITONG INFO-NET CO.,LTD.
 */
package com.titan.demo.camel.utils;

import java.util.Hashtable;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;

import org.apache.camel.Service;
import org.apache.camel.impl.JndiRegistry;


/**
 *
 *
 * @author Administrator
 *
 */
public class CamelUtils {
    public static JndiRegistry jndi() throws Exception {
        Properties properties = new Properties();
        properties.setProperty("java.naming.factory.initial", "org.apache.camel.util.jndi.CamelInitialContextFactory");
        Context context = new InitialContext(new Hashtable<Object, Object>(properties));
        
        JndiRegistry jndi = new JndiRegistry(context);
        return jndi;
    }
    
    public static void close(Service service) {
        try {
            if (service != null) {
                service.stop();
            }            
        } catch (Exception e) {
        }
    }
    public static String log(String name) {
        return "log:"+name+"?showBodyType=false&showBody=true&showExchangePattern=false";
    }
}

